package Day20;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo04 {
    public static void main(String[] args) {
        //单线程线程池
        //  1.判断线程池是否空闲
        //  2.空闲则使用，不空闲则等待空闲之后使用
        ExecutorService service = Executors.newSingleThreadExecutor();
        service.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName() + "锄禾日当午");
            }
        });
        service.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName() + "锄禾日当午");
            }
        });
        service.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName() + "锄禾日当午");
            }
        });

        //pool-1-thread-1锄禾日当午
        //pool-1-thread-1锄禾日当午
        //pool-1-thread-1锄禾日当午
    }
}
